﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zeus.Thunder.Core;

namespace SharpTrainer.Delegates
{
    class DelegateCombine : ITestCase
    {
        public void Run()
        {
            Action<string> sayHiEnglish = name => Console.WriteLine("Hello {0}", name);
            Action<string> sayHiDutch = name => Console.WriteLine("Hallo {0}", name);
            Action<string> sayHiFrench = name => Console.WriteLine("Allo {0}", name);

            Action<string> sendGreetings = null;
            sendGreetings += sayHiEnglish;
            sendGreetings += sayHiDutch;
            sendGreetings("Bart"); // Prints “Hello Bart” and “Hallo Bart”

            sendGreetings -= sayHiEnglish;
            sendGreetings += sayHiFrench;
            sendGreetings("John"); // Prints “Hallo John” and “Allo John”
        }
    }
}
